#include <stdio.h>
#include <stdlib.h>
#include <err.h>
#include <fcntl.h>
#include <unistd.h>

#define WR_SIZE     128
#define RD_SIZE     8


int main(void)
{
    char test[128] = "This just a test~~!";
    char out[128] = "";
    int ret = -1;
    
    int f = open("/dev/hello",O_RDWR);
    
    if(f == -1){
        fprintf(stderr,"Cound not open /dev/hello.\n");
        perror("open error");
        return -1;
    }

    if(WR_SIZE != write(f,test,WR_SIZE)){
        perror("write err");
        fprintf(stderr,"Write data error!.\n");
        perror("[WRITE]");
    }

    lseek(f,5,SEEK_SET);

    if(RD_SIZE != read(f,out,RD_SIZE)){
        fprintf(stderr,"Read data error!\n");
        perror("[READ]");
    }

    fprintf(stdout,"%s\n",out);

    close(f);
}
